import { Component, OnInit, EventEmitter, Output } from "@angular/core";
import {BizfileService} from '../../../../../@core/service/case-review/doc-service/api/bizfile.service'
import { ClueDataService } from "../../../../../@core/service/clue-service/clue-data.service";
@Component({
  selector: 'app-case-filing-notice',
  templateUrl: './case-filing-notice.component.html',
  styleUrls: ['./case-filing-notice.component.scss']
})
export class CaseFilingNoticeComponent implements OnInit {
  @Output('loadSpin') loadSpin = new EventEmitter();

  // 时间
  private date:any = new Date();
  //加载动画
  public loading:boolean = false;
  BizFile: any;

  public isReadonly:boolean = false;
  public doctype: string;     // 文书名称
  public condition: string;   // 新增or审批条件
    // 请求数据
    public filedata: any = {data: {stage: null}};
    public caseType: any;        // 案件环节
  //type选中值
  public treeValue: any;
  //区域数据
  public areaData: any;

  public sortValue: string = "0";
  public getSelectValue:string;
 
  // 时间
  private _letter:any = this.date;
  //docid 如果是修改会传入docid
  public docid:string;
  //form内容
  public formJson: any = {
    year:this.date.getFullYear(),
    mon : this.date.getMonth()+1,
    day : this.date.getDate(),
    partNum:'三',
    sendNum:'一',
    // supCity:JSON.parse(sessionStorage.getItem('organization')).filter(item=>item.orgType =='1')[0].orgName,
    fromMarketSupDep:JSON.parse(sessionStorage.getItem('organizations'))[0].orgName,
  };
  public get letter(){
    return this._letter
  }
  public set letter(val){
    if(val){
      let date:Date = new Date(val);
      this.formJson.year = date.getFullYear();
      this.formJson.mon = date.getMonth()+1;
      this.formJson.day = date.getDate();
    }
    this._letter=val;
}
  constructor(
    public bizService:BizfileService,
    public clueData: ClueDataService,
    ) {
      this.areaData = clueData.area;
     }

  ngOnInit() {
    if(this.docid){ 
      this.bizService.queryBizFileByDocid(this.docid).subscribe(({data}:any)=>{
        this.loadSpin.emit(false);
        if(data){
          if(data.stage) this.getSelectValue = data.stage;
          this.BizFile = data;
          this.formJson = JSON.parse(data.formJson);
          this.letter =  this.formJson.year+'-'+this.formJson.mon+'-'+this.formJson.day
          console.log(this.formJson)
        }
      })
  }else{
  
  }
}
  //tree选择
  treeOnChange(event) {
  }
  selectChange(event){
    this.getSelectValue = event;
  }
}
